package com.taoyibao.hongcanting.dialog;

import android.annotation.SuppressLint;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.taoyibao.hongcanting.R;

/**
 * @author TangAnna
 * @description: 使用相机的弹窗
 * @date :${DATA} 15:08
 */
@SuppressLint("ValidFragment")
public class DialogCamera extends BaseFragmentDialog implements View.OnClickListener {
    private DialogCameraInterface mDialogCameraInterface;
    private TextView mTvCamera;
    private TextView mTvAlbum;

    public DialogCamera(DialogCameraInterface dialogCameraInterface) {
        mDialogCameraInterface = dialogCameraInterface;
    }

    @Override
    public int bindView() {
        return R.layout.dialog_camera;
    }

    @Override
    public void initView(View view) {
        super.initView(view);
        mTvCamera = view.findViewById(R.id.tv_dialogCamera_camera);
        mTvAlbum = view.findViewById(R.id.tv_dialogCamera_album);
        mTvCamera.setOnClickListener(this);
        mTvAlbum.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_dialogCamera_camera://相机
                if (mDialogCameraInterface != null) {
                    mDialogCameraInterface.onCameraListener();
                }
                break;
            case R.id.tv_dialogCamera_album://相册
                if (mDialogCameraInterface != null) {
                    mDialogCameraInterface.onAlbumListener();
                }
                break;
        }
        dismiss();
    }

    @Override
    protected int setAnimation() {
        return 0;
    }

    @Override
    protected int setGravity() {
        return Gravity.BOTTOM;
    }


    public interface DialogCameraInterface {
        /**
         * 选择相机事件
         */
        void onCameraListener();

        /**
         * 选择相册事件
         */
        void onAlbumListener();
    }
}
